package com.dk.controller;


import com.dk.bean.Result;
import com.dk.em.ResultEnum;
import com.dk.pojo.CarCities;
import com.dk.service.CarCitiesService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.naming.Name;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 张成涛
 * @since 2021-08-12
 */
@RestController
@RequestMapping("/car-cities")
public class CarCitiesController {

    @Autowired
    private CarCitiesService carCitiesService;
    @Autowired
    private RedisTemplate redisTemplate;

    @ApiOperation(value = "地区查询")
    @GetMapping
    public Result toSelect(){
       List<CarCities> list = carCitiesService.toSelect();
       System.out.println(list);
       return Result.buildResult(ResultEnum.SUCCESS).setData(list);
    }
    @ApiOperation(value = "地区搜索")
    @PostMapping("search")
    @ApiImplicitParam(name = "citiesName",value = "地区名称",required = true,dataTypeClass = String.class,paramType = "path")
    public Result search(@RequestParam("citiesName") String citiesName){
        CarCities carCities = carCitiesService.search(citiesName);
        return Result.buildResult(ResultEnum.SUCCESS).setData(carCities);
    }
}

